/**
 * This kind of plugin runs very early in the Nuxt lifecycle, before we revive the payload.
 * You will not have access to the router or other Nuxt-injected properties.
 *
 * Note that the "DateTime" string is the type identifier and must
 * be the same on both the reducer and the reviver.
 */
import '@imengyu/vue3-context-menu/lib/vue3-context-menu.css'
import ContextMenu from '@imengyu/vue3-context-menu'
import PerfectScrollbar from 'vue3-perfect-scrollbar'
import 'vue3-perfect-scrollbar/dist/vue3-perfect-scrollbar.css'
import Vue3Lottie from "vue3-lottie";
import {autoAnimatePlugin} from '@formkit/auto-animate/vue'
import MasonryWall from '@yeger/vue-masonry-wall'

// 导入视频播放组件
import VueVideoPlayer from '@videojs-player/vue'
import 'video.js/dist/video-js.css'
// 导入toastify
// import Vue3Toasity, { type ToastContainerOptions } from 'vue3-toastify';
// import 'vue3-toastify/dist/index.css';

// import AIButton from 'vue3-ai'
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker';
import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker';
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
import VueKonva from 'vue-konva'

export default definePayloadPlugin((nuxtApp) => {
    nuxtApp.vueApp.use(ContextMenu)
    nuxtApp.vueApp.use(PerfectScrollbar, {
        watchOptions: true,
        options: {
            suppressScrollX: false,
            suppressScrollY: false
        }
    })
    nuxtApp.vueApp.use(Vue3Lottie, {name: "LottieAnimation"});
    nuxtApp.vueApp.use(autoAnimatePlugin);
    nuxtApp.vueApp.use(MasonryWall);
    nuxtApp.vueApp.use(VueKonva);


    nuxtApp.vueApp.use(VueVideoPlayer)
    // nuxtApp.vueApp.use(AIButton)
    // nuxtApp.vueApp.use(
    //     Vue3Toasity,
    //     {
    //         autoClose: 3000,
    //         // ...
    //     } as ToastContainerOptions,
    // );

    // 注册全局组件
    // nuxtApp.vueApp.component('VueVideoPlayer', VueVideoPlayer)
    self.MonacoEnvironment = {
        getWorker(_, label) {
            if (label === 'json') {
                return new jsonWorker();
            }
            if (label === 'css' || label === 'scss' || label === 'less') {
                return new cssWorker();
            }
            if (label === 'html' || label === 'handlebars' || label === 'razor') {
                return new htmlWorker();
            }
            if (label === 'typescript' || label === 'javascript') {
                return new tsWorker();
            }
            return new editorWorker();
        },
    };
})
